package com.eveinfo.sql;

import java.util.ArrayList;
import java.util.HashSet;

import com.eveinfo.sql.data.Item;
import com.eveinfo.tools.Tools;

public class AllPicturesCache extends Thread {

	private final ArrayList<Item> types;
	private final int pictureSize;

	public AllPicturesCache(ArrayList<Item> types, int pictureSize) {
		setPriority(MIN_PRIORITY);
		this.types = new ArrayList<Item>(types);
		this.pictureSize = pictureSize;
	}

	@Override
	public void run() {
		HashSet<String> pictures = new HashSet<String>();
		ArrayList<Item> types = this.types;
		int pictureSize = this.pictureSize;
		int size = types.size();
		for(int i = 0; i < size; i++){
			String pictureName = null;
			Item type =types.get(i);
			if (type.getIcon().equals("")) {
				pictureName = "icon" + type.getTypeID() + "_" + pictureSize;
			} else {
				pictureName = "icon" + type.getIcon() + "_" + pictureSize;
			}
			pictures.add(pictureName);
		}
		for(String picture : pictures){
			Tools.getItemPicture(picture);
		}
	}
}
